package com.fxd.controller;

import com.fxd.domain.account;
import com.sun.deploy.nativesandbox.comm.Request;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @auther fuxudong
 * @date 2021/1/31 - 16:33
 */
@Controller
@RequestMapping("/param")
public class param {


    @RequestMapping("pa")
    public String testparam(HttpServletRequest request, HttpServletResponse response){
        System.out.println(request);
        String servletPath = request.getServletPath();
        System.out.println(servletPath);
        String contextPath = request.getContextPath();
        System.out.println(contextPath);
        HttpSession session = request.getSession();
        session.setAttribute("name","fxd");
        //request.getRequestDispatcher("WEB-INF/pages/success.jsp").(request,response);
        //response.sendRedirect("响应路径");
        return "success";
    }

    @RequestMapping("saveAccount")
    public String testsave(HttpServletRequest request, account account){
        try{
            //1,解决post请求中文乱码第一种方法
            request.setCharacterEncoding("UTF-8");
        }catch (Exception e){
            e.printStackTrace();
        }

        System.out.println(account);
        return "success";
    }

}
